package com.ruoyi.performance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.common.core.domain.R;


import com.ruoyi.teacher.api.RemoteTeacherService;
import com.ruoyi.teacher.api.domain.TeacherType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.performance.domain.SysPerformanceTemplate;
import com.ruoyi.performance.service.ISysPerformanceTemplateService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 绩效模版Controller
 * 
 * @author ruoyi
 * @date 2024-03-23
 */
@RestController
@RequestMapping("/template")
public class SysPerformanceTemplateController extends BaseController

{
    @Autowired
    private ISysPerformanceTemplateService sysPerformanceTemplateService;




    /**
     * 查询绩效模版列表
     */
    @RequiresPermissions("performance:template:list")
    @GetMapping("/list")
    public TableDataInfo list(SysPerformanceTemplate sysPerformanceTemplate)
    {
        startPage();
        List<SysPerformanceTemplate> list = sysPerformanceTemplateService.selectSysPerformanceTemplateList(sysPerformanceTemplate);
        return getDataTable(list);
    }

    /**
     * 导出绩效模版列表
     */
    @RequiresPermissions("performance:template:export")
    @Log(title = "绩效模版", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPerformanceTemplate sysPerformanceTemplate)
    {
        List<SysPerformanceTemplate> list = sysPerformanceTemplateService.selectSysPerformanceTemplateList(sysPerformanceTemplate);
        ExcelUtil<SysPerformanceTemplate> util = new ExcelUtil<SysPerformanceTemplate>(SysPerformanceTemplate.class);
        util.exportExcel(response, list, "绩效模版数据");
    }

    /**
     * 获取绩效模版详细信息
     */
    @RequiresPermissions("performance:template:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysPerformanceTemplateService.selectSysPerformanceTemplateById(id));
    }

    /**
     * 新增绩效模版
     */
    @RequiresPermissions("performance:template:add")
    @Log(title = "绩效模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPerformanceTemplate sysPerformanceTemplate)
    {
        return toAjax(sysPerformanceTemplateService.insertSysPerformanceTemplate(sysPerformanceTemplate));
    }

    /**
     * 修改绩效模版
     */
    @RequiresPermissions("performance:template:edit")
    @Log(title = "绩效模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPerformanceTemplate sysPerformanceTemplate)
    {
        return toAjax(sysPerformanceTemplateService.updateSysPerformanceTemplate(sysPerformanceTemplate));
    }

    /**
     * 删除绩效模版
     */
    @RequiresPermissions("performance:template:remove")
    @Log(title = "绩效模版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysPerformanceTemplateService.deleteSysPerformanceTemplateByIds(ids));
    }
}
